
async function gopPage(page, index) {
  return new Promise(async (resolve, reject)=>{
    let input = await page.$('#pnum')
    let button = await page.$('#pagebar .pgo')
    await input.type(index)
    page.on('response', async (response)=>{
      let url = response.url()
      if(url.indexOf('http://fund.eastmoney.com/data/rankhandler.aspx')===0) {
        resolve()
        console.log('请求页面数据')
      }
    })
    page.on('requestfailed', (response)=>{
      let url = response.url()
      if(url.indexOf('http://fund.eastmoney.com/data/rankhandler.aspx')===0) {
        console.log('请求失败')
        reject()
      }
    })
    button.click()
  })
}

module.exports = gopPage